﻿using Autodesk.Revit.DB.Mechanical;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RevitProject.SpaceManager.Model
{
    public class SpaceManagerModel : ObservableObject
    {
        private ObservableCollection<SpaceTreeModel> _TreeModels = new ObservableCollection<SpaceTreeModel>();

        /// <summary>
        /// 空间树状内容
        /// </summary>
        public ObservableCollection<SpaceTreeModel> TreeModels
        {
            get { return _TreeModels; }
            set
            {
                SetProperty(ref _TreeModels, value);
            }
        }

        private ObservableCollection<SpaceInfoModel> _SpaceInfos = new ObservableCollection<SpaceInfoModel>();

        /// <summary>
        /// 空间信息表内容
        /// </summary>
        public ObservableCollection<SpaceInfoModel> SpaceInfos
        {
            get { return _SpaceInfos; }
            set
            {
                SetProperty(ref _SpaceInfos, value);
            }
        }

        private string _SearchSpaceName = "";

        /// <summary>
        /// 搜索空间名称
        /// </summary>
        public string SearchSpaceName
        {
            get { return _SearchSpaceName; }
            set
            {
                SetProperty(ref _SearchSpaceName, value);
            }
        }

        private ObservableCollection<string> _SpaceNames = new ObservableCollection<string>();

        /// <summary>
        /// 当前分类的所有空间
        /// </summary>
        public ObservableCollection<string> SpaceNames
        {
            get { return _SpaceNames; }
            set
            {
                SetProperty(ref _SpaceNames, value);
            }
        }

        private string _SpaceClassify = "";

        /// <summary>
        /// 选择的空间类型
        /// </summary>
        public string SpaceClassify
        {
            get { return _SpaceClassify; }
            set
            {
                SetProperty(ref _SpaceClassify, value);
            }
        }

        public List<string> SpaceClassifys { get; set; } = new List<string>() { "房间", "管井", "走廊" };
    }

    public class SpaceTreeModel : ObservableObject
    {
        private string _DisplayContent = "";

        /// <summary>
        /// 显示内容
        /// </summary>
        public string DisplayContent
        {
            get { return _DisplayContent; }
            set
            {
                SetProperty(ref _DisplayContent, value);
            }
        }

        /// <summary>
        /// 父节点
        /// </summary>
        public SpaceTreeModel ParentModel { get; set; }

        /// <summary>
        /// 路由结果
        /// </summary>
        public object RouteResult { get; set; }

        private ObservableCollection<SpaceTreeModel> _SubModels = new ObservableCollection<SpaceTreeModel>();

        /// <summary>
        /// 子集
        /// </summary>
        public ObservableCollection<SpaceTreeModel> SubModels
        {
            get { return _SubModels; }
            set
            {
                SetProperty(ref _SubModels, value);
            }
        }
    }

    public class SpaceInfoModel
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 空间实例
        /// </summary>
        public Space SpaceIns { get; set; }

        /// <summary>
        /// 空间名称
        /// </summary>
        public string SpaceName { get; set; }

        /// <summary>
        /// 空间编号
        /// </summary>
        public string SpaceNum { get; set; }        

        /// <summary>
        /// 空间面积
        /// </summary>
        public double SpaceArea { get; set; }

        /// <summary>
        /// 房间ID
        /// </summary>
        public string RoomID { get; set; }
    }
}
